package com.icedata.sika.bridge

import net.mamoe.mirai.contact.Group
import net.mamoe.mirai.event.events.GroupMessageEvent
import net.mamoe.mirai.event.events.MessageEvent
import net.mamoe.mirai.event.events.UserMessageEvent

/**
 * Sika的基本事件类型
 */
abstract class SikaEvent(val miraiMessageEvent: MessageEvent){

    /**
     * 发送的对象
     * @see SikaUserContact
     */
    val sender: SikaUserContact by lazy {
        return@lazy SikaUserContact(miraiMessageEvent.senderName, miraiMessageEvent.sender)
    }
    /**
     * 发送时间
     */
    val sendTime: Int by lazy {
        return@lazy miraiMessageEvent.time
    }
    /**
     * 发送的消息内容体
     * @see SikaMessageChain
     */
    val message: SikaMessageChain by lazy {
        return@lazy SikaMessageChain(miraiMessageEvent.message)
    }

    abstract override fun toString(): String
}

/**
 * Sika的用户事件
 * @see SikaEvent
 */
class SikaUserEvent(miraiUserEvent: UserMessageEvent): SikaEvent(miraiUserEvent) {
    override fun toString(): String {
        return "Sika:M/User:(${sender.id})${sender.name}:${message}"
    }
}

/**
 * Sika的群事件
 * @see SikaEvent
 */
class SikaGroupEvent(miraiGroupEvent: GroupMessageEvent): SikaEvent(miraiGroupEvent) {

    val sendGroup: SikaGroupContact by lazy {
        return@lazy SikaGroupContact(miraiMessageEvent.subject as Group)
    }

    override fun toString(): String {
        return "Sika:M/Group:(${sendGroup.id})${sendGroup.name}:(${sender.id})${sender.groupName}:${message}"
    }
}


annotation class MiraiBasedAPI
annotation class UserSikaAPI
annotation class MiraiSpecialAPI